<!-- 预付款 -->
<template>
  <div class="goods-sum-box">
    <div>
      {{summariesName}}<span class="value-color">
        {{ summaries || 0 }}元</span>
    </div>
  </div>
</template>

<script>
import { finance } from '@/api'

const billTypeTypeMap = new Map([
  [1, '收款单查询'],
  [2, '付款单查询'],
]);

export default {
  name: "PaymentSlipSummaries",
  props: {
    filter: {
      type: Object,
      default: () => {
        return {}
      }
    }
  },
  data () {
    return {
      summaries: '',
      summariesName: ''
    }
  },
  watch: {
    filter: {
      deep: true,
      immediate: true,
      handler (value) {
        if (value?.page) {
          this.summariesName = billTypeTypeMap.get(this.filter?.billType) || '';
          this.loadSummaries();
        }
      }
    }
  },
  methods: {
    async loadSummaries () {
      const response = await finance.getBillTotal(this.filter);
      if (0 !== response?.code) {
        console.log("获取财务统计数据失败", response)
        return
      }
      this.summaries = response.data;
    }
  }
};
</script>

<style scoped>
.goods-sum-box {
  display: flex;
  padding-top: 20px;
  line-height: 30px;
  color: var(--prev-color-text-ashes);
  padding-right: 80px;
}
.value-color {
  color: var(--prev-color-primary) !important;
}
</style>
